package com.example.xuliehua;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Person person = new Person(18, "小明");
        //Animal animal=new Animal("公","123");
        MoveLife moveLife=new MoveLife(person,100,"陆地");
        Intent intent = new Intent(this,ReadActivity.class);
        //intent.putExtra("MainActivity",(Serializable)(person));
        intent.putExtra("MainActivity",(Serializable) (moveLife));
        startActivity(intent);
    }

    private void writeSerializable() throws IOException {
        Person person = new Person(18, "小明");
        OutputStream outputStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
        objectOutputStream.writeObject(person);//写入操作
        objectOutputStream.close();
    }

    private void readSerializable() throws IOException {

    }
}
